#!/dis/sh.dis
# emu sh initialisation here
load std

user="{cat /dev/user}
home=/usr/^$"user
mount -ac {mntgen} /n
ftrans=()

if {~ $emuhost MacOSX Linux}{
	trfs '#U*' /n/local >[2] /dev/null
	ftrans = $frans '#U*' /n/local
	ghome=/n/local/^`{echo 'echo $HOME' | os sh}
}{~ $emuhost Nt}{
	for i in C D {  # add more drive letters to suit
		trfs '#U' ^ $i ^ ':/' /n/$i >[2] /dev/null
		ftrans = $ftrans '#U' ^ $i ^ ':/'  /n/$i
	}
	ghome=`{os cmd /c 'echo %APPDATA%' |
		tr -d ''| sed -n '
			s/ /␣/g
			s/\\/\//g
			s/^([A-Z]):/\/n\/\1/p'}
}{ else
	ghome=$home
}
lhome=$ghome^/acme-home
mount -a {mntgen} /usr

# setup for 1st time user
if {! ftest -d $lhome}{
	cp -r /usr/inferno $lhome
	bind -c /usr/inferno $home
	mkdir -p $home/tmp
}

bind -c $lhome $home
bind -bc $home/tmp /tmp

cd $home
run $home/lib/profile
